import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state:{//设置全局访问的state
        hasShow:false,
        switchHeadTab:localStorage.getItem('switchHeadTab'),
        crumbs:"首页",
        type:null,
        sid:null,
        user:null,
        userid:null,
        permission:null,
        //设置的初始属性值
        newStorge:{},
		content:[
			{name:'产品批号',details:'1710007',type:'批号',},
			{name:'规格',details:'相当于饮片',type:'规格'},
			{name:'生产日期',details:'2020.08.07',type:'生产日期'},
			{name:'有效期至',details:"2020.09",type:'有效期至'}
		],
		content1:[
			{name:'规格',details:"相当于饮片",type:'规格'},
			{name:'批号',details:"19040009",type:'批号'},
			{name:'生产日期',details:"2019.03.19",type:'生产日期'},
			{name:'有效期至',details:"2022.02",type:'有效期至'}
		],
		content2:[
			{name:'批号',details:"19040021",type:'批号'},
			{name:'临床当量',details:"配方颗粒相当于临床使用饮片量",type:'规格'},
			{name:'生产日期',details:"2019.03.19",type:'生产日期'},
			{name:'有效期至',details:"2022.02",type:'有效期至'},
			{name:'包装规格',details:"每袋装100g",type:'包装规格'},
		],
		jcjg:null,
		dymb:null,
        yl:null,
        kc:null,
        sc:null,
        jc:null,
        zh:null,
        tj:null,
        kl:null,
        fb:null,
        sh:null,
        dy:null,
        qy:null,
        yg:null,
        qx:null,
        gys:null,
        kh:null,
        wl:null,
        jcyj:null,
        gygx:null,
        cpxx:null,
        dw:null,
        grsz:null,
        tzxtsz:null,
        wb:null,
        data:null,
        productLicense:null,
        //图片地址
        uploadImgurl:'',
        imageUrls:'',
        num:0,
        // uploadImgurl:'http://192.168.0.143:8901',
        // imageUrls:'http://192.168.0.143:8901/file/show/',

        // uploadImgurl:'http://192.168.0.130:8901',
        // imageUrls:'http://192.168.0.130:8901/file/show/',


        // uploadImgurl:'http://47.104.241.124:8901',
        // imageUrls:'http://47.104.241.124:8901/file/show/',
        storName: '',
        // pagNum: ''
    },
    getters:{//实时监听state值得变化
        supply(state){
            if(!state.supply){
                state.supply = JSON.parse(sessionStorage.getItem("supply"))
            }
            return state.supply
        },
        user(state){
            if(!state.user){
                state.user = JSON.parse(sessionStorage.getItem("key"))
            }
            return state.user
        },
        userid(state){
            if(!state.userid){
                state.userid = JSON.parse(sessionStorage.getItem("id"))
            }
            return state.userid
        },
        permission(state){
            if(!state.permission){
                state.permission = JSON.parse(sessionStorage.getItem("permission"))
            }
            return state.permission
        },
        wb(state){
            if(!state.wb){
                state.wb = JSON.parse(sessionStorage.getItem("wb"))
            }
            return state.wb
        },
		jcjg(state){
		    if(!state.jcjg){
		        state.jcjg = JSON.parse(sessionStorage.getItem("jcjg"))
		    }
		    return state.jcjg
		},
		dymb(state){
		    if(!state.dymb){
		        state.dymb = JSON.parse(sessionStorage.getItem("dymb"))
		    }
		    return state.dymb
		},
        yl(state){
            if(!state.yl){
                state.yl = JSON.parse(sessionStorage.getItem("yl"))
            }
            return state.yl
        },
        kc(state){
            if(!state.kc){
                state.kc = JSON.parse(sessionStorage.getItem("kc"))
            }
            return state.kc
        },
        sc(state){
            if(!state.sc){
                state.sc = JSON.parse(sessionStorage.getItem("sc"))
            }
            return state.sc
        },
        jc(state){
            if(!state.jc){
                state.jc = JSON.parse(sessionStorage.getItem("jc"))
            }
            return state.jc
        },
        zh(state){
            if(!state.zh){
                state.zh = JSON.parse(sessionStorage.getItem("zh"))
            }
            return state.zh
        },
        tj(state){
            if(!state.tj){
                state.tj = JSON.parse(sessionStorage.getItem("tj"))
            }
            return state.tj
        },
        kl(state){
            if(!state.kl){
                state.kl = JSON.parse(sessionStorage.getItem("kl"))
            }
            return state.kl
        },
        fb(state){
            if(!state.fb){
                state.fb = JSON.parse(sessionStorage.getItem("fb"))
            }
            return state.fb
        },
        sh(state){
            if(!state.fb){
                state.fb = JSON.parse(sessionStorage.getItem("fb"))
            }
            return state.fb
        },
        dy(state){
            if(!state.dy){
                state.dy = JSON.parse(sessionStorage.getItem("dy"))
            }
            return state.dy
        },
        qy(state){
            if(!state.qy){
                state.qy = JSON.parse(sessionStorage.getItem("qy"))
            }
            return state.qy
        },
        yg(state){
            if(!state.yg){
                state.yg = JSON.parse(sessionStorage.getItem("yg"))
            }
            return state.yg
        },
        qx(state){
            if(!state.qx){
                state.qx = JSON.parse(sessionStorage.getItem("qx"))
            }
            return state.qx
        },
        gys(state){
            if(!state.gys){
                state.gys = JSON.parse(sessionStorage.getItem("gys"))
            }
            return state.gys
        },
        kh(state){
            if(!state.kh){
                state.kh = JSON.parse(sessionStorage.getItem("kh"))
            }
            return state.kh
        },
        wl(state){
            if(!state.wl){
                state.wl = JSON.parse(sessionStorage.getItem("wl"))
            }
            return state.wl
        },
        jcyj(state){
            if(!state.jcyj){
                state.jcyj = JSON.parse(sessionStorage.getItem("jcyj"))
            }
            return state.jcyj
        },
        gygx(state){
            if(!state.gygx){
                state.gygx = JSON.parse(sessionStorage.getItem("gygx"))
            }
            return state.gygx
        },
        cpxx(state){
            if(!state.cpxx){
                state.cpxx = JSON.parse(sessionStorage.getItem("cpxx"))
            }
            return state.cpxx
        },
        dw(state){
            if(!state.dw){
                state.dw = JSON.parse(sessionStorage.getItem("dw"))
            }
            return state.dw
        },
        grsz(state){
            if(!state.grsz){
                state.grsz = JSON.parse(sessionStorage.getItem("grsz"))
            }
            return state.grsz
        },
        data(state){
            if(!state.data){
                state.data = JSON.parse(sessionStorage.getItem("data"))
            }
            return state.data
        },
        tzxtsz(state){
            if(!state.tzxtsz){
                state.tzxtsz = JSON.parse(sessionStorage.getItem('tzxtsz'))
            }
        },

    },
    mutations:{//唯一允许改变state
        setHasShow(state,payload){
            state.hasShow = payload
        },
        setSwitchHeadTab(state,payload){
            state.switchHeadTab = payload
            localStorage.setItem('switchHeadTab',payload)
            let temp = localStorage.getItem('switchHeadTab')
            if(temp){
                state.switchHeadTab = temp
            }
        },

        setCrumbs(state,v){
            state.crumbs = v
        },

		setsupply(state,v){
		    state.supply = v
		    sessionStorage.setItem("supply",JSON.stringify(v))
		},
        setname(state,v){
            state.user = v
            sessionStorage.setItem("key",JSON.stringify(v))
        },
        setnameid(state,v){
            state.userid = v
            sessionStorage.setItem("id",JSON.stringify(v))
        },
        setpermission(state,v){
            state.permission = v
            sessionStorage.setItem("permission",JSON.stringify(v))
        },
        removename(state,v){
            state.user = null
            sessionStorage.removeItem("key")
        },
        setStorge(state,v){
            state.newStorge = v
        },

        setyl(state,v){
            state.yl = v
            sessionStorage.setItem("yl",JSON.stringify(v))
        },
		setjcjg(state,v){
		    state.jcjg = v
		    sessionStorage.setItem("jcjg",JSON.stringify(v))
		},
		setdymb(state,v){
		    state.dymb = v
		    sessionStorage.setItem("dymb",JSON.stringify(v))
		},
        setkc(state,v){
            state.kc = v
            sessionStorage.setItem("kc",JSON.stringify(v))
        },
        setsc(state,v){
            state.sc = v
            sessionStorage.setItem("sc",JSON.stringify(v))
        },
        setjc(state,v){
            state.jc = v
            sessionStorage.setItem("jc",JSON.stringify(v))
        },
        setzh(state,v){
            state.zh = v
            sessionStorage.setItem("zh",JSON.stringify(v))
        },
        settj(state,v){
            state.tj = v
            sessionStorage.setItem("tj",JSON.stringify(v))
        },
        setkl(state,v){
            state.kl = v
            sessionStorage.setItem("kl",JSON.stringify(v))
        },
        setfb(state,v){
            state.fb = v
            sessionStorage.setItem("fb",JSON.stringify(v))
        },
        setsh(state,v){
            state.sh = v
            sessionStorage.setItem("sh",JSON.stringify(v))
        },
        setdy(state,v){
            state.dy = v
            sessionStorage.setItem("dy",JSON.stringify(v))
        },
        setqy(state,v){
            state.qy = v
            sessionStorage.setItem("qy",JSON.stringify(v))
        },
        setyg(state,v){
            state.yg = v
            sessionStorage.setItem("yg",JSON.stringify(v))
        },
        setqx(state,v){
            state.qx = v
            sessionStorage.setItem("qx",JSON.stringify(v))
        },
        setgys(state,v){
            state.gys = v
            sessionStorage.setItem("gys",JSON.stringify(v))
        },
        setkh(state,v){
            state.kh = v
            sessionStorage.setItem("kh",JSON.stringify(v))
        },
        setwl(state,v){
            state.wl = v
            sessionStorage.setItem("wl",JSON.stringify(v))
        },
        setjcyj(state,v){
            state.jcyj = v
            sessionStorage.setItem("jcyj",JSON.stringify(v))
        },
        setgygx(state,v){
            state.gygx = v
            sessionStorage.setItem("gygx",JSON.stringify(v))
        },
        setcpxx(state,v){
            state.cpxx = v
            sessionStorage.setItem("cpxx",JSON.stringify(v))
        },
        setProductLicense(state,v){
            state.productLicense = v
            sessionStorage.setItem("setProductLicense",JSON.stringify(v))
        },
        setdw(state,v){
            state.dw = v
            sessionStorage.setItem("dw",JSON.stringify(v))
        },
        setgrsz(state,v){
            state.grsz = v
            sessionStorage.setItem("grsz",JSON.stringify(v))
        },
        settzxtsz(state,v){
            state.tzxtsz = v
            sessionStorage.setItem("tzxtsz",JSON.stringify(v))
        },
        setwb(state,v){
            state.wb = v
            sessionStorage.setItem("wb",JSON.stringify(v))
        },
        setdata(state,v){
            state.data = v
            sessionStorage.setItem("data",JSON.stringify(v))
        },
		setContent2(state,v){
			state.content2 = v
			// sessionStorage.setItem("data",JSON.stringify(v))
		},
        setnum(state,v){
            state.num = v
        },
        settype(state,v){
            state.type = v
        },
        setsid(state,v){
            state.sid = v
        },
        setimg(state,v){
            state.imageUrls = v
        },
        setuploadimg(state,v){
            state.uploadImgurl = v
        },
        // 设置类型
        setStorName(state,v){
            state.storName = v
            console.log(v)
        },
        removeRuform(state,v) {
            state.newStorge = null
        },
        // 设置分页
        setPagNum(state,v){
            state.pagNum = v
        }
    },
    actions:{//触发更改

    },

})

export default store
